package com.excel;


/**
 * 用于设置excel表头的和并列
 * 
 * @author mike
 * 
 */
public class MergedColumn {

    private String mergedColumn;
    /**
     * 需要合并的列名,顺序决定了在Excel中的显示位置
     */
    private String[] columnNames;

    /**
     * 串格式合并列
     */
    public void mergeColumn(String mergedName, String []columnNames) {
	this.mergedColumn = mergedName;
	this.columnNames = columnNames;
    }
    
    /**
     * 通过字符串格式合并列
     * @param formatNames
     * 格式为：mergedName(column1|column2[|columnN])
     */
    public void mergeColumn(String formatNames) {
	int leftFlag = formatNames.indexOf(Constant.HEADFORMAT_SPRACELEFT_FLAG);
	int rightFlag = formatNames.lastIndexOf(Constant.HEADFORMAT_SPRACERIGHT_FLAG);
	String columns = formatNames.substring(leftFlag+1, rightFlag);
	this.mergedColumn = formatNames.substring(0, leftFlag);	
	this.columnNames = columns.split("|");
    }
    
    
    
    
}
